<?php
include_once '../meihe/common.php';
if ($islogin2 == 1) {
} else exit("<script language='javascript'>window.location.href='./login.php';</script>");
?>
<?php
if (isset($_GET['kw'])) {
  $sql = " url='{$_GET['kw']}'";
  $numrows = $DB->count("SELECT count(*) from meihe_report WHERE{$sql} and upzid='{$userrow['zid']}'");
  $con = '包含 ' . $_GET['kw'] . ' 的共有 <b>' . $numrows . '</b> 条记录';
  $link = '&kw=' . $_GET['kw'];
} else {
  $numrows = $DB->count("SELECT count(*) from meihe_report WHERE 1 and upzid='{$userrow['zid']}'");
  $sql = " 1";
  $con = '你共有 <b>' . $numrows . '</b> 条记录';
}
?>
<form name="form1" id="form1">
  <div style="white-space:nowrap;overflow-x: auto;">
    <table class="layui-table layuiadmin-page-table">
      <thead>
        <tr>
          <th>
            <div class="custom-control custom-checkbox"><input name="chkAll1" type="checkbox" id="chkAll1" onclick="selectAll(this);" value="checkbox" class="custom-control-input"><label class="custom-control-label" for="chkAll1"></label></div>ID
          </th>
          <th>生成网址</th>
          <th>是否会员</th>
          <th>生成方式</th>
          <th>时间</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <?php
        $pagesize = isset($_GET['num']) ? intval($_GET['num']) : 30;
        $pages = ceil($numrows / $pagesize);
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
        $offset = $pagesize * ($page - 1);
        $rs = $DB->query("SELECT * FROM meihe_report WHERE{$sql} and upzid='{$userrow['zid']}' order by id desc limit $offset,$pagesize");
        while ($res = $DB->fetch($rs)) {
          $url_arr = parse_url($res['url']);
          $domain = $url_arr['host'];
          $rowb = $DB->get_row("SELECT * FROM meihe_list WHERE domain='" . $domain . "' limit 1");
          if ($rowb['type'] == 1) {
            $sfhy = '<a class="btn btn-effect-ripple btn-xs btn-success">是会员</a>';
          } else {
            $sfhy = '<a class="btn btn-effect-ripple btn-xs btn-info">非会员</a>';
          }
          $content = explode('*', $res['content']);
          $content = mb_substr($content[0], 0, 16, 'utf-8');
          echo '<tr><td><div class="custom-control custom-checkbox"><input type="checkbox" name="checkbox[]" id="workorder' . $res['id'] . '" value="' . $res['id'] . '" class="custom-control-input"><label class="custom-control-label" for="workorder' . $res['id'] . '"></label></div>' . $res['id'] . '</td><td><a href="' . htmlspecialchars($res['url']) . '" rel="noreferrer" target="_blank">' . htmlspecialchars($res['url']) . '</a></td><td>' . $sfhy . '</td><td>' . $res['reason'] . '</td><td>' . $res['date'] . '</td><td><span class="btn btn-effect-ripple btn-xs btn-info" style="background:linear-gradient(to right, #7C4DFF,#536DFE,#9575CD);" onclick="recharge(' . $res['id'] . ')"><font color="white">修改标题</font></span> <a href="javascript:void(0)" onclick="layer.alert(\'防洪识别码：' . $res["uid"] . '\')" data-toggle="tooltip"  class="btn btn-effect-ripple btn-xs btn-success">识别码</a></td></tr>';
        }
        ?>
      </tbody>
    </table>
    <div class="form-group mb-3">
      <input type="hidden" name="content" />
      <label for="example-input-normal" style="font-weight: 500">操作：
        <select class="form-control" style="display: inline;width: auto;" name="aid">
          <option selected>批量操作</option>
          <option value="2">&gt;删除选中</option>
        </select>
        <button class="btn btn-sm btn-primary" type="button" onclick="change()">确定</button>
      </label>
    </div>
  </div>
</form>
<div class="text-center">
  <?php
  #分页
  $pageList = new Page($numrows, $pagesize, 1, $link ?? '');
  echo $pageList->showPage();
  ?>
</div>
<script>
  $("#blocktitle").html('<?php echo $con ?>');
</script>